#ifndef WINDOWVISIBILITYHELPER_H
#define WINDOWVISIBILITYHELPER_H

#include "common.h"

class WindowVisibilityHelper;

#include "WMCallback.h"

#define HiddenPositionValue 27154

class WindowVisibilityHelper
{
public:
	WindowVisibilityHelper(HINSTANCE hInstance, bool removeFromTaskbar = true);
	~WindowVisibilityHelper();
	void Hide(HWND hWnd);
	void Show(HWND hWnd);
	void Recover();
	bool IsHidden(HWND hWnd);
	void SetTag(LPVOID tag);
	LPVOID GetTag();
private:
	void DeleteTaskbarTab(HWND hWnd);
	void AddTaskbarTab(HWND hWnd);
	POINT SetHiddenPosition(HWND hWnd);
	void SetNormalPosition(HWND hWnd);
	void RemoveFromFlip3D(HWND hWnd);
	void AddToFlip3D(HWND hWnd);

	LPVOID tag;
	bool removeFromTaskbar;
	WMCallback* wmCallback;

	static set<WindowVisibilityHelper*> instances;
	static HWINEVENTHOOK hWinEventHook;
	static UINT WM_TASKBARCREATED;

	static VOID CALLBACK WinEventProc(HWINEVENTHOOK hWinEventHook,DWORD dwEvent,HWND hWnd,LONG idObject,LONG idChild,DWORD idEventThread,DWORD dwmsEventTime);
	static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LPVOID tag);
	static BOOL CALLBACK EnumWindowsProc_Recover(HWND hWnd, LPARAM lParam);
	static BOOL CALLBACK EnumWindowsProc_RemoveTaskbarButtonAgain(HWND hWnd, LPARAM lParam);
};

#endif
